package es.aqua.aquac.il.dal.impl;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import es.aqua.aquac.exception.GeneralDAOException;
import es.aqua.aquac.il.dal.interfaces.LecturaDAO;
import es.aqua.aquac.il.domain.Lectura;
import es.aqua.aquac.il.domain.Propietario;

public class LecturaDAOImpl extends GeneralDAOImpl<Lectura> implements LecturaDAO {

	@Override
	@Transactional(readOnly = true)
	@SuppressWarnings("unchecked")
	public List<Lectura> obtenerLecturasPropietario(Propietario propietario) throws GeneralDAOException {
		try {
			return (List<Lectura>) getJpaTemplate().getEntityManager().createNamedQuery("Lectura.obtenerLecturasPropietario")
					.setParameter("id", propietario.getId()).getResultList();
		} catch (Exception e) {
			logger.error("Error en LecturaDAOImpl " + e.getMessage());
			throw new GeneralDAOException(e.getMessage(), e.toString());
		}
	}
}
